﻿/* 
 * author: www.cnblogs.com/luminji
 * date  : 2011/12/09
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Luminji.Core.Enterprise.RBAC;
using Luminji.Core.Json;
using Luminji.Exam.Infrastructure.Repositories.Papers;
using Luminji.Exam.Model.Papers;
using Luminji.Core.Serialization;
using System.Configuration;
using Luminji.Core.Xaml;
using Luminji.ExamWeb.Helpers;
using Luminji.Exam.Application;
using Luminji.Infrastructure.UnitOfWork;

namespace Luminji.ExamWeb.Controllers
{
    public class PaperController : BaseExamControl
    {
        private PaperService _service;
        
        public PaperController()
        {
            IUnitOfWork uw = new UnitOfWork();
            _service = new PaperService(new PaperRepository(uw), uw );
        }

        public ActionResult Index(string papername, string papercode)
        {
            Paper paper = _service.GetPaperWithDetailDetailByPaperCode(papercode);
            ViewBag.Paper = paper;
            ViewBag.PaperCode = papercode;
            ViewBag.PaperJson = JsonHelper.ToJson(paper);
            return View();
        }

        public ActionResult SavePaper(Paper paper)
        {
            if (Request.IsAjaxRequest())
            {
                return Json("success");
            }
            else
            {
                return View();
            }

        }

        public ActionResult ShowMorePaper(int? showType)
        {
            var papers = _service.GetPapers(showType, this.CurrentUser);
            if (papers != null)
            {

            }
            return View();
        }

    }
}
